home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
rbbs_pc
/
r2dbf121.zip
/
MBF2NUM.C
< prev
Wrap
Text File
|
1991-02-22
|
1KB
|
50 lines
/*
Microsoft Binary Format to Number: Emulates BASIC's CVS()
Eric J. Givler
2/20/91
*/
#include "i:\clipper\nandef.h"
#include "i:\clipper\extend.h"
#include "i:\tc\include\stdio.h"
CLIPPER Cvs() /* void main(void) */
{
unsigned char s[4]; /* = "0000"; */
unsigned long l; /* result */
unsigned char e; /* exponent */
char *str1;
char sh,i;
str1 = _parc(1); /* strcpy( s, _parc(1)); */
s[0] = *str1;
s[1] = *(str1+1);
s[2] = *(str1+2);
s[3] = *(str1+3);
l = 0;
if (s[3] == 0)
{
_retnl(l);
}
else
{
i = 0;
e = s[3] & 127; /* exponent byte 127 normalized */
s[2] = s[2] | 128; /* turn on 1st bit of byte 3! */
for(i=0; i < 3; i++) /* while (i < 3) */
{
sh = e - 8 * (i+1);
if (sh < 0)
{
sh = -sh;
l += (long)s[2-i] >> sh;
}
else l += (long)s[2-i] << sh;
}
_retnl(l);
}
}